<html>
<head>
  <script src="../../../resources/run-after-layout-and-paint.js"></script>
  <style>
    body {
      height: 1000px;
    }
    #redbox {
      background-color: red;
      position: absolute;
      top: 50px;
      left: 50px;
      height: 50px;
      width: 50px;
    }
    #greenbox {
      background-color: green;
      position: absolute;
      top: 450px;
      left: 50px;
      height: 50px;
      width: 50px;
    }
  </style>
  <script>
    function doTest()
    {
      runAfterLayoutAndPaint(function() {
        // Scroll red box off screen and scroll green box into same place.
        window.scrollTo(0, 400);
      }, true);
    }

    window.addEventListener('load', doTest, false);
  </script>
</head>
<body>
  <div id="redbox"></div>
  <div id="greenbox"></div>
</body>
</html>
